import { useState } from 'react'
let list = []
function RandomList() {
  // 写一个组件名叫RandomList，组件上有个按钮和一个随机数的列表，每按一下按钮向列表增加一个随机数，初始列表为空数组

  const [count, setCount] = useState(0)
  return (
    <div>
      <p>{count}</p>
      <button
        onClick={() => {
          list.push(count)
          setCount(Math.random() * 10 + 10)
          //   console.log(Array.isArray(list), list)
        }}
      >
        添加
      </button>
      <ul>
        {list.length === 0 ? (
          <li>暂无数据</li>
        ) : (
          list.map((res, i) => {
            return <li key={i}>{res}</li>
          })
        )}
      </ul>
    </div>
  )
}
export default RandomList
